package com.ttg.pojo;

import com.ttg.utils.Assert;

import java.io.File;

public class BatchProfitPojo extends BasePojo {
    private String batchNo;
    private Double totalAmount;
    private Integer countRecord;
    private String fileDigest;
    private File batchFile;
    private String fileParameterName;

    public String getFileParameterName() {
        return fileParameterName;
    }

    public void setFileParameterName(String fileParameterName) {
        this.fileParameterName = fileParameterName;
    }

    public String getBatchNo() {
        return batchNo;
    }

    @Override
    public String toString() {
        return "BatchProfitPojo{" +
                "batchNo='" + batchNo + '\'' +
                ", totalAmount=" + totalAmount +
                ", countRecord=" + countRecord +
                ", fileDigest='" + fileDigest + '\'' +
                ", batchFile=" + batchFile +
                ", fileParameterName='" + fileParameterName + '\'' +
                "} " + super.toString();
    }

    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;

        this.allParameters.put("batchNo",batchNo);
    }

    public Double getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;

        this.allParameters.put("totalAmount", String.valueOf(totalAmount));
    }

    public Integer getCountRecord() {
        return countRecord;
    }

    public void setCountRecord(Integer countRecord) {
        this.countRecord = countRecord;

        this.allParameters.put("countRecord", String.valueOf(countRecord));
    }

    public String getFileDigest() {
        return fileDigest;
    }

    public void setFileDigest(String fileDigest) {
        this.fileDigest = fileDigest;

        this.allParameters.put("fileDigest",fileDigest);
    }

    public File getFile() {
        return batchFile;
    }

    public void setFile(File file) {
        if ((file != null) && file.exists() && ( !file.exists() || file.isFile() )) {
            this.batchFile = file;
        } else {
            throw new IllegalArgumentException("批量上传文件[" + file + "]不合法,请检查其是否存在且是否是一个文件.");
        }

    }

    public void attachFile(File batchFile, String fileParameterName) {
        if (( batchFile != null ) && batchFile.exists() && ( !batchFile.exists() || batchFile.isFile() )) {
            Assert.hasText(fileParameterName, "fileParameterName参数值不能为空白");
            this.batchFile         = batchFile;
            this.fileParameterName = fileParameterName;
        } else {
            throw new IllegalArgumentException("批量上传文件[" + batchFile + "]不合法,请检查其是否存在且是否是一个文件.");
        }
    }
}
